<!DOCTYPE html>
<html lang="en">
<link rel="stylesheet" href="/layui/css/layui.css" media="all">
<head>
    <meta charset="UTF-8">
    <title>模型管理</title>
</head>
<body>
<div id="top">
</div>
<h2><strong>
    <button style="float: left;">
        <a href="/">首页</a>
    </button>
    <button style="float: left; margin-left: 5px">
        <a href="/model-list.html">模型列表</a>
    </button>
    <button style="float: left; margin-left: 5px">
        <a href="/users-events-list">事件列表</a>
    </button>
</strong></h2>
<hr>
<a href="javascript: AJAX.POST('/models/newModel')" type="button" class="layui-btn layui-btn-primary">绘制流程</a>
<table border="1" id="model-list" class="layui-table">
    <tr>
        <td>模型编号</td>
        <td>模型名称</td>
        <td>版本</td>
        <td>创建时间</td>
        <td>操作</td>
    </tr>
    <script id="models" type="text/html">
        <tr>
            <td>模型编号</td>
            <td>模型名称</td>
            <td>版本</td>
            <td>创建时间</td>
            <td>操作</td>
        </tr>
        {{each rows.list}}
        <tr>
            <td>{{$value.id}}</td>
            <td>{{$value.name}}</td>
            <td>{{$value.version}}</td>
            <td>{{$value.createTime}}</td>
            <td>
                <a href="/editor?modelId={{$value.id}}">编辑</a>
                <a href="javascript: AJAX.DELETE('/models/{{$value.id}}')">删除</a>
                <a href="javascript: AJAX.POST('/models/{{$value.id}}/deployment')">发布</a>
            </td>
        </tr>
        {{/each}}
    </script>
</table>
<hr>
<h2><strong>部署列表</strong></h2>
<hr>
<table border="1" id="deployment-list" class="layui-table" lay-skin="line">
    <tr>
        <td>编号</td>
        <td>名称</td>
        <td>部署时间</td>
        <td>操作</td>
    </tr>
    <script id="deployments" type="text/html">
        <tr>
            <td>编号</td>
            <td>名称</td>
            <td>部署时间</td>
            <td>操作</td>
        </tr>
        {{each rows.list}}
        <tr>
            <td>{{$value.id}}</td>
            <td>{{$value.name}}</td>
            <td>{{$value.deploymentTime}}</td>
            <td><a href="javascript: AJAX.DELETE('/deployments/{{$value.id}}')">删除</a></td>
        </tr>
        {{/each}}
    </script>
</table>
<script src="/lib/js/jquery-1.10.2.min.js"></script>
<script src="/lib/js/jquery.cookie.js"></script>
<script src="/js/ajax-util.js"></script>
<script src="/lib/js/template.js"></script>

<script>
    $(function () {
        AJAX.GET("/models", null
            , function (result) {
                var html = template("models", result);
                $("#model-list").html(html);
            });

        AJAX.GET("/deployments", null
            , function (result) {
                var html = template("deployments", result);
                $("#deployment-list").html(html);
            });
    })
</script>
</body>
</html>
